include ../../Makefile.conf
XM=
compile:
	mkdir -p tmp dist
	find tmp -name "*.class" -exec rm  '{}' ';'
	-cp -r ./src/WEB-INF/classes/* ../core/src/* tmp/ 2> /dev/null
	-find tmp -type d -name ".svn" -exec rm -rf '{}' ';' 2> /dev/null
	$(JAVAC) -cp $(BERKELEYDB_JE_LIB):$(SERVLETAPI):$(JSP_API) -sourcepath tmp \
		tmp/fr/cephb/locustree/LT*.java \
		tmp/fr/cephb/locustree/admin/*.java \
		tmp/fr/cephb/j2ee/tag/*.java \
		tmp/fr/cephb/locustree/*/*.java
	$(JAR) cvf dist/locustree.jar -C tmp .
	rm -rf tmp

test-dump:compile
	$(JAVA) -enableassertions -cp $(BERKELEYDB_JE_LIB):$(MYSQL_JDBC):dist/locustree.jar fr.cephb.locustree.LTModel -db-home $(DEFAULT_BDB_DIR) -p dump -log-level ALL
test-svg:compile
	$(JAVA) -enableassertions -cp $(BERKELEYDB_JE_LIB):dist/locustree.jar \
	fr.cephb.locustree.LTSvg \
	-db-home $(DEFAULT_BDB_DIR) \
	-o hg18 -s 100000  -c "chr1"  -log-level ALL > ${HOME}/jeter.svg
test-ascii:compile
	$(JAVA) -enableassertions -cp $(BERKELEYDB_JE_LIB):dist/locustree.jar fr.cephb.locustree.LTAscii -db-home $(DEFAULT_BDB_DIR) -s 100000 -o hg18 -c "chr1" -log-level ALL
test-search:compile
	$(JAVA) -enableassertions -cp $(BERKELEYDB_JE_LIB):$(MYSQL_JDBC):dist/locustree.jar fr.cephb.locustree.LTSearch -db-home $(DEFAULT_BDB_DIR) -log-level ALL -e 'rs486' -n 5

load-basic:compile
	$(JAVA) $(XM) -enableassertions -cp $(BERKELEYDB_JE_LIB):$(MYSQL_JDBC):dist/locustree.jar \
		fr.cephb.locustree.admin.LTLoadComponents \
			-db-home $(DEFAULT_BDB_DIR) \
			-log-level ALL \
			-R update \
			configs/hg18.organism.xml \
			configs/hg18.chromosomes.xml \
			configs/hg18.tracks.xml 


test-load:load-basic
	$(JAVA) $(XM) -enableassertions -cp $(BERKELEYDB_JE_LIB):$(MYSQL_JDBC):dist/locustree.jar \
		fr.cephb.locustree.admin.LTLoadComponents \
			-db-home $(DEFAULT_BDB_DIR) \
			-nt \
			-log-level ALL \
			-R update \
			configs/hg18.testloader.xml	

war:
	mkdir -p tmp dist
	find tmp -name "*.class" -exec rm  '{}' ';'
	-cp -r ./src/*  tmp/ 2> /dev/null
	-cp -r ../core/src/* tmp/WEB-INF/classes/
	-find tmp -type d -name ".svn" -exec rm -rf '{}' ';' 2> /dev/null
	$(JAVAC) -cp $(BERKELEYDB_JE_LIB):$(SERVLETAPI):$(JAKARTA_TAGLIB_DIR):$(JSP_API) -sourcepath tmp/WEB-INF/classes/ \
			tmp/WEB-INF/classes/fr/cephb/j2ee/tag/*.java \
			tmp/WEB-INF/classes/fr/cephb/locustree/svg/*.java \
			tmp/WEB-INF/classes/fr/cephb/locustree/*.java
	mkdir -p tmp/WEB-INF/lib
	mkdir -p tmp/WEB-INF/tld
	cp -f $(BERKELEYDB_JE_LIB) tmp/WEB-INF/lib/
	cp -f $(JAKARTA_TAGLIB_DIR)/lib/*.jar tmp/WEB-INF/lib/
	cp -f $(JAKARTA_TAGLIB_DIR)/tld/*.tld tmp/WEB-INF/tld
	$(JAR) cvf dist/locustree.war -C tmp .
	rm -rf tmp
dist/webappisdown.jar:
	mkdir -p dist
	wget -O $@ "http://lindenb.googlecode.com/files/webappisdown.jar"

webdown:dist/webappisdown.jar
	java -jar dist/webappisdown.jar dist/locustree.war
	$(call deploy-war,dist/locustree.war)
	rm dist/locustree.war

deploy:war
	$(call deploy-war,dist/locustree.war)
clean:
	rm -rf tmp dist/locustree.jar dist/locustree.war dist/webappisdown.jar
	-find tmp -name "*.class" -exec rm '{}' ';'


	
